package com.lwc.web;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * render page
 *
 * @author liwancheng
 */
@Controller
@Slf4j
public class PageController {


    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String hello(ModelMap model) {
        return "hello";
    }

    @ExceptionHandler(Exception.class)
    public void resolveException(HttpServletResponse response, Exception ex) throws IOException {
        log.error(ex.getMessage(), ex);
        response.sendError(500, ex.getMessage());
    }

}
